package com.fcgzs.springboot.controller;


import com.fcgzs.springboot.pojo.Checkitem;
import com.fcgzs.springboot.service.CheckitemService;
import com.fcgzs.springboot.util.PageResult;
import com.fcgzs.springboot.util.QueryPageBean;
import com.fcgzs.springboot.util.Result;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wjd
 * @since 2021-10-12
 */
@RestController
@RequestMapping("/checkitem")
public class CheckitemController {

    @Reference //注意是dubbo类型
    private CheckitemService checkitemService;

    //添加、编辑检查项
    @RequestMapping("/addCheckitemInfo")
    public Result addCheckitemInfo(@RequestBody Checkitem checkitem){
        System.out.println("111");
        return checkitemService.addCheckitemInfo(checkitem);
    }

    //弹出编辑窗口时回显数据
    @RequestMapping("/getOneCheckitemInfo")
    public Result getOneCheckitemInfo(Integer id){
        Result oneCheckitemInfo = checkitemService.getOneCheckitemInfo(id);
        return oneCheckitemInfo;
    }

    //检查项：全表分页、模糊查询
    @RequestMapping("/queryPageInfo")
    public PageResult queryPageInfo(@RequestBody QueryPageBean queryPageBean){
        return checkitemService.queryPageInfo(queryPageBean);
    }

    //检查项：删除单个
    @RequestMapping("/deleteCheckitemInfo")
    @PreAuthorize("hasAuthority('CHECKITEM_DELETE')")
    public Result deleteCheckitemInfo(Integer id){
        return checkitemService.deleteCheckitemInfo(id);
    }

    //检查组：获取所有检查项
    @RequestMapping("/getAllCheckitemInfo")
    public Result getAllCheckitemInfo(){
        return checkitemService.getAllCheckitemInfo();
    }

}

